import { Controller, Post, Get, Query } from '@nestjs/common';
import {BookService} from './book.service'
import {PartService} from '../part/part.service'

@Controller('main')
export class BookController {

    constructor(private bookSevice:BookService, private partService:PartService){}

    @Post('read/list')
    findBook () {
        return this.bookSevice.findList()
    }

    @Post('read/partList')
    async findPart (@Query() params) {
       
        params.chapterId = params.chapterId || 1;
        console.log(params);
        const book = await this.bookSevice.findOne(params.bookId)

        // const catalog = await this.catalogServie.findList()

        const list = await this.partService.findList(params)
        const chapterId = params.chapterId;
        return {
            code: 0,
            partId: 123,
            chapterId: chapterId,
            bookName: book.bookName,
            title: '奋斗第一天',
            partList: list
        }
    }

    @Post('annotation/bookHotAnnotationList')
    findAnnotation () {
        return []
    }

    @Post('read/myinfo')
    findMyInfo () {
        return []
    }

    // @Post('read/chapterlist')
    // findChapter () {
    //     return this.bookSevice.findList()
    // }

    @Get('create')
    createBook () {
        return this.bookSevice.create()
    }
}
